package com.vit.springController;

import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

import com.vit.domain.User;
/**
 * Validator class to validate User data
 * @author i80260
 *
 */
public class UserValidator implements Validator{
	@Override
	public void validate(Object arg0, Errors arg1)
	{
		System.out.println("Validating...");
		User user = (User) arg0;
        if (user.getFirstName().isEmpty()) 
        {
        	arg1.rejectValue("firstName", "empty","First Name Cannot be empty.");
        }        
	}
	
	@Override
	public boolean supports(Class<?> arg0) {
		return User.class.equals(arg0);
	}
}
